package Test;

// Shape抽象类
abstract class Shape {
    // 抽象方法：计算面积
    public abstract double getArea();
    // 抽象方法：计算周长
    public abstract double getPerimeter();
}

// Square类继承Shape
class Square extends Shape {
    private double side;

    public Square(double side) {
        this.side = side;
    }

    @Override
    public double getArea() {
        return side * side;
    }

    @Override
    public double getPerimeter() {
        return 4 * side;
    }
}

// Circle类继承Shape
class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public double getPerimeter() {
        return 2 * Math.PI * radius;
    }
}
public class Test {

    public static void main(String[] args) {

        Square square=new Square(3.14);
        System.out.println(square.getArea());
        System.out.println(square.getPerimeter());
        Circle circle=new Circle(3);
        System.out.println(circle.getArea());
        System.out.println(circle.getPerimeter());

    }
}
